package com.jeasonzhao.report.msg;

import com.jeasonzhao.commons.utils.Algorithms;
import com.jeasonzhao.report.model.ReportColumn;
import com.jeasonzhao.report.model.Report;
import com.jeasonzhao.report.model.ReportDatabaseConfiguration;
import com.jeasonzhao.report.model.ReportDict;
import com.jeasonzhao.report.codes.ReportColumnTypes;
import com.jeasonzhao.report.model.ReportParam;

public class MessageCodes
{
    private MessageCodes()
    {
        super();
    }

    public static String getDescription(ReportColumn rpt)
    {
        if(null == rpt)
        {
            return "[Unknown Report Column Defination]";
        }
        else
        {
            return rpt.getTitle() + ":" +
                (rpt.getColumnType().equals(ReportColumnTypes.CalcColumn) ? rpt.getCalcScript() : rpt.getFieldName());
        }
    }

    public static String getDescription(ReportParam rpt)
    {
        if(null == rpt)
        {
            return "[Unknown Report Parameters Defination]";
        }
        else
        {
            return rpt.getTitle() + ":" + rpt.getParam();
        }
    }

    public static String getLongDescription(Report rpt)
    {
        if(null == rpt)
        {
            return "[Unknown Report Defination]";
        }
        else
        {
            return rpt.getTitle() + ":" + rpt.getReportId() + "(" + rpt.getConfigSrc() + ")";
        }
    }

    public static String getLongDescription(ReportDatabaseConfiguration db)
    {
        if(null == db)
        {
            return "[Unknown Database Defination]";
        }
        else
        {
            return db.getDatabaseName() + ":" + db.getDatabaseId() + "(" + db.getConfigSrc() + ")";
        }
    }

    public static String getDescription(ReportDict dict)
    {
        if(null == dict)
        {
            return "[Unknown Dictionary Defination]";
        }
        else
        {
            return dict.getName() + ":" + dict.getId();
        }
    }

    public static String getDescription(Report rpt)
    {
        if(null == rpt)
        {
            return "[Unknown Report Defination]";
        }
        else
        {
            return rpt.getTitle() + ":" + rpt.getReportId();
        }
    }

    public static String getDescription(ReportDatabaseConfiguration db)
    {
        if(null == db)
        {
            return "[Unknown Database Defination]";
        }
        else
        {
            return db.getDatabaseName() + ":" + db.getDatabaseId();
        }
    }

    public static String getLongDescription(ReportDict dict)
    {
        if(null == dict)
        {
            return "[Unknown Dictionary Defination]";
        }
        else
        {
            return dict.getName() + ":" + dict.getId() + "(" + dict.getConfigSrc() + ")";
        }
    }

    public static final String get(String key)
    {
        return LocalizationManager.getInstance().get(MessageCodes.class,key);
    }

    public static final String format(String key,Object ...parameter)
    {
        return Algorithms.replaceStringByPosition(LocalizationManager.getInstance().get(MessageCodes.class,key),parameter);
    }

    //****************************Logger
     @Message(encode = "zh_cn:系统;en:SystemInfo;")
     public static final String LOGLEVEL_SYSTEMINFO = "LOGLEVEL_SYSTEMINFO";

    @Message(encode = "zh_cn:致命;en:Fatal;")
    public static final String LOGLEVEL_FATAL = "LOGLEVEL_FATAL";

    @Message(encode = "zh_cn:错误;en:Error;")
    public static final String LOGLEVEL_ERROR = "LOGLEVEL_ERROR";

    @Message(encode = "zh_cn:警告;en:Warnning;")
    public static final String LOGLEVEL_WARNNING = "LOGLEVEL_WARNNING";

    @Message(encode = "zh_cn:信息;en:Information;")
    public static final String LOGLEVEL_INFO = "LOGLEVEL_INFO";

    @Message(encode = "zh_cn:调试;en:Debug;")
    public static final String LOGLEVEL_DEBUG = "LOGLEVEL_DEBUG";

    //****************************Renders
     @Message(encode = "zh_cn:合计;en:Summary;")
     public static final String RENDER_Summary = "RENDER_Summary";

    @Message(encode = "zh_cn:小计;en:Subtotal;")
    public static final String RENDER_Subtotal = "RENDER_Subtotal";

    @Message(encode = "zh_cn:输入参数值;en:Input parameters;")
    public static final String RENDER_INPUTPARAMETR = "RENDER_INPUTPARAMETR";

    @Message(encode = "zh_cn:查询;en:Query;")
    public static final String RENDER_QUERYBUTTON = "RENDER_QUERYBUTTON";

    @Message(encode = "zh_cn:取消;en:Cancel;")
    public static final String RENDER_CANCELBUTTON = "RENDER_CANCELBUTTON";

    //**************************** Configurations
     @Message(encode = "zh_cn:新增数据库连接配置{0};en:Add a new database configuration {0} into the repository;")
     public static final String CFG_ADDDATABASE = "CFG_ADDDATABASE";

    @Message(encode = "zh_cn:新增字典配置{0};en:Add a new dictionary configuration {0} into the repository;")
    public static final String CFG_ADDDICTIONARY = "CFG_ADDDICTIONARY";

    @Message(encode = "zh_cn:新增报表配置{0};en:Add a new report configuration {0} into the repository;")
    public static final String CFG_ADDREPORT = "CFG_ADDREPORT";

    @Message(encode = "zh_cn:新增数据库连接池{0},Driver={1},URL={2};en:Create a new database connection pool for {0},Driver={1},URL={2};")
    public static final String CFG_DB_CREATE_A_NEW_POOL = "CFG_DB_CREATE_A_NEW_POOL";

    @Message(encode = "zh_cn:正在加载主配置文件{0};en:Loading mainly configuration file {0};")
    public static final String CFG_MAINLY_LOADING = "CFG_MAINLY_LOADING";

    @Message(encode = "zh_cn:正在检查服务器配置的主日志文件...;en:Loading logger configuration...;")
    public static final String CFG_INIT_LOGGER = "CFG_INIT_LOGGER";

    @Message(encode = "zh_cn:切换系统日志到{0}...;en:Change logger to {0}...;")
    public static final String CFG_CHANGE_LOGGER = "CFG_CHANGE_LOGGER";

    @Message(encode = "zh_cn:配置了一个系统日志节点，但是其类为空，仍旧使用当前的系统日志接口;en:configured a logger node, but the class name is empty!;")
    public static final String CFG_NO_CLASS_LOGGER = "CFG_NO_CLASS_LOGGER";

    @Message(encode = "zh_cn:增加新的日志接口{0}错误，类必须实现接口{1};en:Add a new logger {0} Error, the class must implements the interface {1};")
    public static final String CFG_LOGGER_ERROR = "CFG_LOGGER_ERROR";

    @Message(encode = "zh_cn:正在检查服务器配置的资源配置器...;en:Loading resource-loaders...;")
    public static final String CFG_INIT_LOADER = "CFG_INIT_LOADER";

    @Message(encode = "zh_cn:增加新的资源配置器到仓库{0};en:Add a new resource-loader into respository {0};")
    public static final String CFG_ADD_NEW_LOADER = "CFG_ADD_NEW_LOADER";

    @Message(encode = "zh_cn:增加新的资源配置器到仓库{0}错误，类必须实现接口{1};en:Add a new resource-loader into respository {0} Error, the class must implements the interface {1};")
    public static final String CFG_LOADER_ERROR = "CFG_LOADER_ERROR";

    @Message(encode = "zh_cn:刷新资源配置，操作类{0};en:Refreshing resources by the class {0};")
    public static final String CFG_LOADER_REFRESH = "CFG_LOADER_REFRESH";

    //**************************** Report Runtime
     @Message(
         {"zh_cn","因存在二次过滤，强制将分页信息设置为不分页"
         ,"en","Remove all pagnating information due to has some fiters works"})
     public static final String RPT_NOPAGENATE_FITER = "RPT_NOPAGENATE_FITER";

    @Message(
        {"zh_cn","计算旋转之前的表格数据..."
        ,"en","Caculting dataset before rotating/pivoting..."})
    public static final String RPT_CALC_BEFOREROTATE = "RPT_CALC_BEFOREROTATE";

    @Message(
        {"zh_cn","计算旋转之后的表格数据..."
        ,"en","Caculting dataset after rotating/pivoting..."})
    public static final String RPT_CALC_AFTERROTATE = "RPT_CALC_AFTERROTATE";

    @Message(
        {"zh_cn","旋转表格..."
        ,"en","Rotating/pivoting dataser..."})
    public static final String RPT_CALC_ROTATE = "RPT_CALC_ROTATE";

    @Message(
        {"zh_cn","按照维度自动汇总表格的数据行..."
        ,"en","Summary all rows by dimensions..."})
    public static final String RPT_CALC_SHRINKBYDIMENSIONS = "RPT_CALC_SHRINKBYDIMENSIONS";

    @Message(
        {"zh_cn","小计和合计表格..."
        ,"en","Summarying and subtotaling dataset..."})
    public static final String RPT_CALC_SUMMARY = "RPT_CALC_SUMMARY";

    @Message(
        {"zh_cn","小计和合计表格中的表达式计算..."
        ,"en","Summarying and subtotaling dataset, calulating all expression generated..."
    })
    public static final String RPT_CALC_SUMMARY2 = "RPT_CALC_SUMMARY2";

    @Message(
        {"zh_cn","处理纵向扩展..."
        ,"en","Expanding dataset vertical..."
    })
    public static final String RPT_CALC_VERTICAL_EXPAND = "RPT_CALC_VERTICAL_EXPAND";

    @Message(
        {"zh_cn","处理格式化信息..."
        ,"en","Formating cells..."
    })
    public static final String RPT_CALC_FORMAT = "RPT_CALC_FORMAT";

    @Message(
        {"zh_cn","处理预警和渲染信息..."
        ,"en","Handling cell alerts and rendering..."
    })
    public static final String RPT_CALC_ALERTS = "RPT_CALC_ALERTS";

    @Message(
        {"zh_cn","附加渲染器..."
        ,"en","Handling appended decorators..."
    })
    public static final String RPT_CALC_APPENDDECORATORS = "RPT_CALC_APPENDDECORATORS";

    @Message(
        {"zh_cn","处理自定义表头..."
        ,"en","Handling customized table header..."
    })
    public static final String RPT_CALC_CUSTOMIZED_HEADER = "RPT_CALC_CUSTOMIZED_HEADER";

    @Message(
        {"zh_cn","处理完成！"
        ,"en","Done!"
    })
    public static final String RPT_CALC_DONE = "RPT_CALC_DONE";

    @Message(
        {"zh_cn","计算图形所需要的数据..."
        ,"en","Caculating datas for charts..."
    })
    public static final String RPT_CALC_CHARTS = "RPT_CALC_CHARTS";

    @Message(
        {"zh_cn","输出到设备..."
        ,"en","Rendering to device..."
    })
    public static final String RPT_RENDER = "RPT_RENDER";

    @Message(
        {"zh_cn","生成报表\"{0}\"错误:{1}"
        ,"en","Could not generate report {0}: {1}"
    })
    public static final String EXCEPTION_TITLE = "EXCEPTION_TITLE";



    @Message(encode = "zh_cn:刷新;en:Refresh;")
    public static final String TOOLBAR_REFRESH = "TOOLBAR_REFRESH";

    @Message(encode = "zh_cn:过滤数据;en:Filters;")
    public static final String TOOLBAR_FILTER = "TOOLBAR_FILTER";

    @Message(encode = "zh_cn:自定义报表;en:Custermize;")
    public static final String TOOLBAR_CUSTOMERIZE = "TOOLBAR_CUSTOMERIZE";

    @Message(encode = "zh_cn:导出数据;en:Export;")
    public static final String TOOLBAR_EXPORT = "TOOLBAR_EXPORT";

    @Message(encode = "zh_cn:输入参数;en:Parmaeters;")
    public static final String TOOLBAR_PARAMTERS = "TOOLBAR_PARAMTERS";

    @Message(encode = "zh_cn:导出到Excel;en:Export to Excel;")
    public static final String TOOLBAR_EXPORT_EXCEL = "TOOLBAR_EXPORT_EXCEL";

    @Message(encode = "zh_cn:导出到PDF;en:Export to PDF;")
    public static final String TOOLBAR_EXPORT_PDF = "TOOLBAR_EXPORT_PDF";

    @Message(encode = "zh_cn:导出到Word;en:Export to Word;")
    public static final String TOOLBAR_EXPORT_WORD = "TOOLBAR_EXPORT_WORD";

    @Message(encode = "zh_cn:保存定义;en:Save;")
    public static final String TOOLBAR_SAVE = "TOOLBAR_SAVE";

}
